Agnostic Programming: Learning to Design and Test Basic Programming Algorithms by Kinga Laura Dobolyi

Agnostic Programming: Learning to Design and Test Basic Programming Algorithms by Kinga Laura Dobolyi

Author:Kinga Laura Dobolyi [Dobolyi, Kinga Laura]
Language: eng
Format: epub
Published: 2015-08-13T22:00:00+00:00


Exercise: Given the top-left coordinates of two tiles, write a program that will shift the coordinates of one of the tiles right and/or down so that the coordinates represent the closest coordinates between these tiles.

Answer: Let’s start with test cases. Order of the coordinates-as-pairs does not matter, because we said earlier that we guaranteed that tiles would be given sorted order, so a tile that is higher or more left than the second one (we could sort tiles in our program to enforce this, if we wanted). The partition here are coordinates where one coordinate needs to be shifted down, one coordinate that needs to be shifted to the right, and one coordinate that needs to be shifted both down and right. (There is no such input that the coordinates do not need to be shifted, as this would mean they are the same tile).



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.